<template>
  <van-cell-group class="winning_record_item" @click="onclick()">
    <van-row class="item_title">
      <van-col span="20">
        <span>{{ activityTitle }}</span>
        <van-icon name="arrow"></van-icon>
      </van-col>
      <van-col span="4">
        <span>{{ transactionStatus }}</span>
      </van-col>
    </van-row>
    <van-row class="item_content">
      <van-col span="6">
        <van-image
          width="2rem"
          height="2rem"
          :src="imageUrl"
        />
      </van-col>
      <van-col span="12">
        <van-row class="prize_name">{{ prizeInfoName }}</van-row>
        <div v-if="transactionStatus === ''">
          <van-row>等待商家发货</van-row>
        </div>
        <div v-else>
          <van-row>
            未领取
          </van-row>
        </div>
      </van-col>
      <van-col span="6" class="">
        x1
      </van-col>
    </van-row>
  </van-cell-group>
</template>

<script>
import {CellGroup} from "vant";
import {Row, Col, Icon, Dialog} from "vant";
import {Image as VanImage} from "vant"

export default {
  name: "WinningRecordItem",
  components: {
    [CellGroup.name]: CellGroup,
    [Row.name]: Row,
    [Col.name]: Col,
    [Icon.name]: Icon,
    Dialog,
    VanImage
  },
  props: {
    activityTitle: {
      type: String,
      default: "惊喜大抽奖"
    },
    transactionStatus: {
      type: String,
      default: "未领取"
    },
    imageUrl: {
      type: String,
      default: "https://img01.yzcdn.cn/vant/cat.jpeg"
    },
    prizeInfoName: {
      type: String,
      default: "大香肠"
    },
    deliveryAddress: {
      type: String,
      default: "未知地点"
    },
    shippingAddress: {
      type: String,
      default: "鸡窝山大学"
    },
    courierNum: {
      type: String,
      default: "23432423223"
    }
  },
  created() {
    if (this.$store.state.user.userInfo.city !== "" && this.$store.state.user.userInfo.area !== null){
      this.transactionStatus = ""
    }
  },
  methods: {
    onclick() {
      if (this.$store.state.user.userInfo.city === "" || this.$store.state.user.userInfo.area === null) {
        Dialog.confirm({
          title: "完善信息",
          message: "请完善个人信息方便领取奖品"
        }).then(() => {
          this.$router.push("/address_edit")
        }).catch(() => {

        })
      }else if(this.transactionStatus === "未领取"){
        Dialog.alert({
          title: "领取成功",
          message: "活动方将在2~5个工作日发送奖品"
        })
      }
    }
  }
}
</script>

<style scoped>
.winning_record_item {
  font-size: 14px;
  height: 125px;
}

.item_title {
  font-size: 18px;
  padding: 5px;
  border-bottom: 2px solid rgb(247, 246, 251);
  font-weight: 700;
}

.item_content {
  padding: 5px;
}

.prize_name {
  font-size: 16px;
  font-weight: 700;
}
</style>
